#include "gd_web_server.h"

#include <godot_cpp/core/class_db.hpp>

GdWebServer::GdWebServer() {
}

GdWebServer::~GdWebServer() {
}

void GdWebServer::_bind_methods() {
	ClassDB::bind_method(D_METHOD("start", "port"), &GdWebServer::start, DEFVAL(8080));
	ClassDB::bind_method(D_METHOD("stop"), &GdWebServer::stop);
	ClassDB::bind_method(D_METHOD("handle_request", "method", "url", "headers", "body"), &GdWebServer::handle_request);
}

void GdWebServer::start(int port) {
	// run server, listening port

	// create sockets, bind ports, and listen for connections
}

void GdWebServer::stop() {
	// stop server
}

Dictionary GdWebServer::handle_request(String method, String url, Dictionary headers, String body) {
	Dictionary response;
	response["status"] = 200;
	response["body"] = "{\"message\": \"ok!\"}";
	return response;
}